package com.xindacloud.sms.console.system.controller;


import com.xindacloud.sms.console.result.Result;
import com.xindacloud.sms.console.result.ResultGenerator;
import com.xindacloud.sms.console.system.dto.SmsAgentRouteDTO;
import com.xindacloud.sms.console.system.entity.SmsAgentRoute;
import com.xindacloud.sms.console.system.service.ISmsAgentRouteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Api(tags = {"短信通道路由接口模块"})
@RestController
@RequestMapping("/api/v1/sms-agent-route")
public class SmsAgentRouteController {

    @Autowired
    ISmsAgentRouteService agentRouteService;

    @ApiOperation(value = "添加路由服务", response = SmsAgentRoute.class)
    @PostMapping("")
    public Result addSmsAgentRoute(@ApiParam(value = "短信通道路由服务", name = "smsAgentRouteDTO")
                                   @RequestBody SmsAgentRouteDTO smsAgentRouteDTO) {
        return ResultGenerator.genSuccessResult(agentRouteService.saveSmsRoute(SmsAgentRoute
                .builder()
                .routeService(smsAgentRouteDTO.getRouteName())
                .build()));
    }

    @ApiOperation(value = "查询所有路由服务列表", response = SmsAgentRoute.class)
    @GetMapping("/query")
    public Result querySmsAgentRouteList() {
        return ResultGenerator.genSuccessResult(agentRouteService.queryAllAgentRoute());
    }

}
